Skip to content

Conversation

@js-murph
Copy link
Collaborator

@js-murph js-murph commented Jan 23, 2026

What?

This PR adds support for private gomod repositories via github. This builds on the existing git caching capabilities within Cachew.

Why?

So that we are able to cache private go modules.

Tests

Unit testing has been added, but manual verification has also been performed...

First create a configuration:

git {
  mirror-root = "./state/git-mirrors"
  clone-depth = 1000
  bundle-interval = "24h"
}

disk {
  root = "./state/cache"
  limit-mb = 250000
  max-ttl = "8h"
}

gomod {
  proxy = "https://proxy.golang.org"
  private-paths = ["github.com/block"]
}

Then test a private repository.

curl http://127.0.0.1:8080/gomod/github.com/<...snip>.zip --output test
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8255k  100 8255k    0     0  82932      0  0:01:41  0:01:41 --:--:-- 2454k

curl http://127.0.0.1:8080/gomod/github.com/<...snip>.zip --output test2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8255k  100 8255k    0     0   243M      0 --:--:-- --:--:-- --:--:--  244M

@js-murph js-murph requested a review from alecthomas as a code owner January 23, 2026 01:36
@js-murph js-murph marked this pull request as draft January 23, 2026 01:36
Base automatically changed from johnm/investigate-goproxy to main January 23, 2026 03:08
js-murph added a commit that referenced this pull request Jan 26, 2026
# What?

Migrates the git clone component of the git strategy into a separate API

# Why?

Experimentation on implementing private repo support for the gomod
strategy in #56 revealed we are
likely better off separating the git clone behaviour so that it can be
shared between multiple strategies.
@js-murph js-murph force-pushed the johnm/goproxy-private-repo-support branch from e4569a0 to 2a077c9 Compare January 26, 2026 23:57
@js-murph js-murph marked this pull request as ready for review January 27, 2026 02:59
@js-murph js-murph requested a review from a team as a code owner January 27, 2026 02:59
@js-murph js-murph removed the request for review from a team January 27, 2026 02:59
@js-murph js-murph requested a review from alecthomas January 27, 2026 02:59
@js-murph js-murph mentioned this pull request Jan 27, 2026
@js-murph js-murph changed the title feat: private repo support feat: gomod private repo support Jan 28, 2026
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we testing this, do we have a way?

Comment on lines +73 to +77
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, errors.Wrap(err, "get user home directory")
}
mirrorRoot = filepath.Join(homeDir, ".cache", "cachew", "gomod-git-mirrors")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should require a config path so we can put all state into a single directory, like we do with the other git mirrors.

Also remind me again why we can't reuse our existing git mirrors?

}

// Create gitclone manager for private repositories
cloneManager, err := gitclone.NewManager(ctx, gitclone.Config{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should construct the gitclone manager in main and inject it into the gomod strategy. This'll require some refactoring of the factory functions, so I'll do that post merge.

f, err := w.Create(prefix + "go.mod")
assert.NoError(t, err)
if err != nil {
panic(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was changed, but the old behaviour was correct - we should never panic in tests.

@alecthomas alecthomas merged commit fb7cc24 into main Jan 29, 2026
6 checks passed
@alecthomas alecthomas deleted the johnm/goproxy-private-repo-support branch January 29, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants